package bs;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;

public class ServerReader extends  Thread{
    private Socket socket;
    public ServerReader(Socket socket)
    {
        this.socket = socket;
    }
    @Override
    public void run() {
        //响应网页请求
        try {
            OutputStream os = socket.getOutputStream();
            PrintStream pos = new PrintStream(os);
            pos.println("HTTP/1.1 200 OK");
            pos.println("Content-Type:text/html;charset=utf-8");
            pos.println(); // 必须换行
            //输出今天的日期，并给予样式：水平居中，紫色
            pos.println("<html>");
            pos.println("<head><title>服务器响应</title></head>");
            pos.println("<body>");
            pos.println("<div style='color:purple;font-size:60px;text-align:center'>");
            pos.println("今天是：" + new java.util.Date());
            pos.println("<div style='color:black;font-size:120px;text-align:center'>你好<div>");
            pos.println("</div>");
            pos.println("</body>");
            pos.println("</html>");
            pos.println();
            pos.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
